<template>
  <div>
    <el-row class="card" :gutter="22">
      <el-col
        v-for="(item, index) in dataList"
        :key="index"
        :xs="8"
        :sm="8"
        :md="8"
        :lg="8"
        :xl="8"
        style="margin-bottom: 22px"
      >
        <div class="card-item" @click="linkToJobDetail(item.id)">
          <p class="item-title">{{ item.jobName }}</p>
          <p class="item-price">
            {{ item.lowestSalary }}-{{ item.highestSalary }}元/天
          </p>
          <p class="item-address">{{ item.city }}</p>
          <div class="item-msg">
            <span class="item-text">{{ item.practicePeriod }}个月</span>
            <span class="line"></span>
            <span class="item-text">{{ item.workPeriod }}</span>
            <span class="line"></span>
            <span class="item-text">{{ item.education }}</span>
            <span class="line" v-if="item.identify"></span>
            <span class="item-text" v-if="item.identify">{{
              ["在校", "应届"][item.identify]
            }}</span>
          </div>
          <div class="item-bottom">
            <img
              v-if="!item.companyLogo"
              src="@/assets/images/search-icon.png"
              alt=""
              class="bottom-img"
            />
            <img
              v-if="item.companyLogo"
              :src="item.companyLogo"
              alt=""
              class="bottom-img"
            />
            <span class="bottom-title">{{
              item.companyShortName || item.companyName
            }}</span>
            <span class="line"></span>
            <span class="bottom-text">{{ item.industry }}</span>
          </div>
        </div>
      </el-col>
    </el-row>
     <div class="job_main_row">
        <div class="job-swiper-wrapper">
          <div  class="job-swiper-slide"
          >
            <div
              class="item"
              v-for="(it, i) in dataList"
              :key="i"
              @click="linkToJobDetail(it.id)"
            >
              <div class="title">
                <span class="jobName">{{ it.jobName }}</span>
                <span class="salary"
                  >{{ it.lowestSalary }}-{{ it.highestSalary }}元/天</span
                >
              </div>
              <div class="txtRow">
                <span class="text">{{ it.workPeriod }}</span>
                <span class="lines"></span>
                <span class="text">{{ it.practicePeriod || 0 }}个月</span>
                <span class="lines" v-if="it.identify"></span>
                <span v-if="it.identify" class="text">{{
                  ["在校", "应届"][it.identify]
                }}</span>
                <span class="lines" v-if="it.education"></span>
                <span v-if="it.education" class="text">{{ it.education }}</span>
              </div>

              <div class="item_bot">
                <img :src="it.companyLogo" class="logo" />
                <span class="companyName">{{ it.companyName }}</span>
                <span class="city">{{ it.city }}</span>
              </div>
            </div>
          </div>
        </div>
      </div>
  </div>
  
</template>

<script>
export default {
  // 组件名称
  name: "search",
  // 组件参数 接收来自父组件的数据
  props: {
    dataList: Array,
  },
  // 局部注册的组件
  components: {},
  // 组件状态值
  data() {
    return {};
  },
  // 计算属性
  computed: {},
  // 侦听器
  watch: {},
  // 组件方法
  methods: {
    linkToJobDetail(id) {
      this.$router.push({
        path: `/jobDetail/${id}`,
      });
    },
  },
  /**
   * 组件实例创建完成，属性已绑定，但DOM还未生成，$ el属性还不存在
   */
  created() {},
  /**
   * el 被新创建的 vm.$ el 替换，并挂载到实例上去之后调用该钩子。
   * 如果 root 实例挂载了一个文档内元素，当 mounted 被调用时 vm.$ el 也在文档内。
   */
  mounted() {},
};
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="less" scoped>
.job_main_row{
  display: none;
}
.card {
  display: block;
  // display: grid;
  // grid-template-columns: repeat(auto-fill, 520px);
  // grid-gap:22px;
  position: relative;
  .card-item {
    height: 220px;
    background: #ffffff;
    border-radius: 10px;
    border: 1px solid #d4d6da;
    position: relative;
    padding: 14px 14px;
    cursor: pointer;
    .line {
      width: 1px;
      height: 14px;
      opacity: 0.7;
      border: 1px solid #9ca8be;
      display: inline-block;
      margin: 0 18px;
    }
    .item-title {
      font-size: 22px;
      font-weight: 500;
      color: #37383d;
      max-width: 76%;
      line-height: 49px;
      margin-bottom: 8px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .item-price {
      font-size: 18px;
      color: #9597a0;
      line-height: 20px;
      margin-bottom: 20px;
    }
    .item-address {
      font-size: 17px;
      color: #9597a0;
      line-height: 17px;
      position: absolute;
      top: 30px;
      right: 18px;
    }
    .item-msg {
      .item-text {
        font-size: 15px;
        color: #9597a0;
        line-height: 16px;
      }
    }
    .item-bottom {
      margin-top: 20px;
      border-top: 0.5px dashed #9597a0;
      padding-top: 10px;
      width: 100%;
      display: flex;
      flex-flow: row nowrap;
      align-items: center;
      justify-content: flex-start;
      .bottom-img {
        width: 50px;
        height: 50px;
        border-radius: 50%;
        border: 1px solid #d5d8db;
        margin-right: 14px;
      }
      .bottom-title {
        font-size: 18px;
        color: #37383d;
        line-height: 30px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
      .bottom-text {
        flex: 1;
        font-size: 16px;
        color: #9597a0;
        line-height: 28px;
        white-space: nowrap;
      }
    }
  }
}

@media screen and (max-width: 480px) {
  .card {
    display: none;
  }
  .job_main_row {
    display: block;
    width: 100%;
    padding: 0.1rem 0 0;
    height: auto;
    overflow: hidden;
    .swiper-wrapper{
      display: none;
    }
    .job-swiper-wrapper {
        .job-swiper-slide {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        padding: 0 10px;
        // height: 380px;
        .item {
          width: 100%;
          height: 140px;
          background: #ffffff;
          border: 1px solid #ebebeb;
          // box-shadow: 0px 0px 33px 2px rgba(124, 124, 124, 0.17);
          box-shadow: none;
          border-radius: 10px;
          margin-bottom: 10px;
          margin-right: 0;
          transition-duration: 0.3s;
          padding: 15px 15px 0;
          position: relative;
          font-family: MicrosoftYaHei;
          line-height: 20px;
          font-weight: 400;
          overflow: hidden;
          cursor: pointer;
          & > div {
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
          }
          .title {
            width: 100%;
            margin-bottom: 15px;
            display: flex;
            justify-content: space-between;
            .jobName {
              font-size: 16px;
              color: #000;
              overflow: hidden;
              white-space: nowrap;
              text-overflow: ellipsis;
              max-width: 185px;
            }
            .salary {
              font-size: 13px;
              color: #fa606a;
              overflow: hidden;
              white-space: nowrap;
              text-overflow: ellipsis;
              max-width: calc(100% - 185px);
            }
          }
          .txtRow {
            font-size: 14px;
            font-weight: 400;
            color: #999999;
            line-height: 15px;
            margin-bottom: 14px;
            .lines {
              width: 1px;
              height: 15px;
              opacity: 0.7;
              border-left: 1px solid #9ca8be;
              margin: 0 10px;
            }
          }

          &:hover .jobName {
            color: #15389a;
          }
          .item_bot {
            width: 100%;
            position: relative;
            height: 55px;
            display: flex;
            align-items: center;
            justify-content: space-between;
            border-top: 1px dashed #ebebeb;
            font-size: 14px;
            font-family: MicrosoftYaHeiLight;
            font-weight: 400;
            color: #999999;
            line-height: 17px;
            padding-left: 38px;
            .companyName {
              overflow: hidden;
              white-space: nowrap;
              text-overflow: ellipsis;
              max-width: 185px;
            }
            .logo {
              position: absolute;
              width: 30px;
              height: 30px;
              border-radius: 50%;
              left: 0;
              top: 50%;
              border: 1px solid #D4D6DA;
              transform: translateY(-50%);
            }
          }
          &:nth-child(3),
          &:nth-child(6) {
            margin-right: 0;
          }
          &:hover {
            // box-shadow: 0px 0px 25px 2px rgba(124, 124, 124, 0.41);
            box-shadow: none;
            // transform: scale(1.02);
          }
        }
      }
    }
  }
}
</style>
